package com.everyday.practice.leetCode;

import java.util.HashMap;
import java.util.Map;

/**
 * @description:
 * @author: zhengbo
 * @time: 2022/1/15 12:58
 */
public class Title169 {
    public static int singleNumber(int[] nums) {
        Map<Integer,Integer> map=new HashMap();
        for (int num:nums){
            Integer orDefault = map.getOrDefault(num,0);
            map.put(num,++orDefault);
        }
        for (int key:map.keySet()){
            if (map.get(key)>(nums.length/2)){
                return key;
            }
        }
        return 0;
    }
}
